package com.liuxu.topnews;

import android.app.Application;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.widget.CheckBox;

import com.liuxu.topnews.bean.App;
import com.liuxu.topnews.utils.RootUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyApplication extends Application {
    public static Context context;
    public static Application application;
    public static int width;
    public static int height;
    public static int widthPixels;
    public static int heightPixels;
    public static boolean permission;
    public static boolean Pause;
    public static boolean sleep;
    public static boolean autoclear;
    public static boolean update;
    public static boolean updateCheck;
    public static boolean must;
    public static boolean random_read;
    public static boolean video_read;
    public static boolean float_window;
    public static String updateinfo;
    public static String UpClassName;
    public static String NowClassName;
    public static Map topics=new HashMap();
    public static AssetManager assetManager;
    public static List<App> globalapps;
    public static App globalapp;
    public static int cycle_time;
    public static List<CheckBox> checkBoxList;
    public static SparseBooleanArray checklist;

    @Override
    public void onCreate() {
        super.onCreate();
        init();
    }
    public void init(){
        context = getApplicationContext();
        application=getApplication();
        width=720;
        height=1280;
        permission=false;
        updateCheck=true;
        Pause=false;
        assetManager=getAssets();
        checkBoxList=new ArrayList<>();
        checklist=new SparseBooleanArray();
        DisplayMetrics dm = getResources().getDisplayMetrics();
        widthPixels=dm.widthPixels;
        heightPixels=dm.heightPixels;
        RootUtils.getInstance();
        topics.put("200","成功");
        topics.put("100","失败");
        topics.put("10","注册码错误");
        topics.put(2,"系统");
        topics.put(1,"按键");
        topics.put(0,"触控");
        topics.put("口令", BuildConfig.Host+getResources().getString(R.string.tourl));
        topics.put("注册",BuildConfig.Host+getResources().getString(R.string.reurl));
        topics.put("运行",BuildConfig.Host+getResources().getString(R.string.idurl));
        topics.put("解绑",BuildConfig.Host+getResources().getString(R.string.caurl));
        topics.put("更新",BuildConfig.Host+getResources().getString(R.string.upurl)+BuildConfig.tokenhead);
        Log.v("应用","初始化成功");
    }

    public static Context getContext() {
        return context;
    }

    public static Application getApplication() {
        return application;
    }

    public static List<App> getGlobalapps() {
        return globalapps;
    }

    public static void setGlobalapps(List<App> globalapps) {
        MyApplication.globalapps = globalapps;
    }


    public static Map getTopics(){
        return topics;
    }

    public  void setUpdateinfo(String updateinfo){
        this.updateinfo=updateinfo;
    }

    public  String getUpdateinfo(){
        return updateinfo;
    }

}
